/******************************************************************************

  File Name     : alg_struct.h
  Version       : Initial Draft
  Author        : tongzhilin
  Created       : 2020/8/7
  Last Modified :
  Description   : alg_struct
  Function List :
  History       :
  1.Date        : 2020/8/7
    Author      : tongzhilin
    Modification: Created file

******************************************************************************/
#pragma once
#include "mp_types.h"

#define ALG_MODEL_NAME_SIZE (128)
#define ALG_MODEL_NUM       (128)
#define FEATURE_SIZE_MAX    (512)
#define LMK_POINTS_MAX      (106)

typedef void* ALG_HANDLE;

/*
** Image type,the same as svp image type
*/
typedef enum
{
    ALG_IMAGE_TYPE_U8C1           =  0x0,
    ALG_IMAGE_TYPE_S8C1           =  0x1,

    ALG_IMAGE_TYPE_YUV420SP       =  0x2,       /*YUV420 SemiPlanar*/
    ALG_IMAGE_TYPE_YUV422SP       =  0x3,       /*YUV422 SemiPlanar*/
    ALG_IMAGE_TYPE_YUV420P        =  0x4,       /*YUV420 Planar */
    ALG_IMAGE_TYPE_YUV422P        =  0x5,       /*YUV422 planar */

    ALG_IMAGE_TYPE_S8C2_PACKAGE   =  0x6,
    ALG_IMAGE_TYPE_S8C2_PLANAR    =  0x7,

    ALG_IMAGE_TYPE_S16C1          =  0x8,
    ALG_IMAGE_TYPE_U16C1          =  0x9,

    ALG_IMAGE_TYPE_U8C3_PACKAGE   =  0xa,
    ALG_IMAGE_TYPE_U8C3_PLANAR    =  0xb,

    ALG_IMAGE_TYPE_S32C1          =  0xc,
    ALG_IMAGE_TYPE_U32C1          =  0xd,

    ALG_IMAGE_TYPE_S64C1          =  0xe,
    ALG_IMAGE_TYPE_U64C1          =  0xf,

    ALG_IMAGE_TYPE_BUTT
}ALG_IMAGE_TYPE_E;

/*
** Alg Image
*/
typedef struct nnIMAGE_S
{
    UINT64              au64PhyAddr[3]; /* RW;The physical address of the image.hisilicon need*/
    UINT64              au64VirAddr[3]; /* RW;The virtual address of the image */
    UINT32              au32Stride[3];  /* RW;The stride of the image */
    UINT32              u32Width;       /* RW;The width of the image */
    UINT32              u32Height;      /* RW;The height of the image */
    ALG_IMAGE_TYPE_E    enType;         /* RW;The type of the image */
}ALG_IMAGE_S;

typedef enum
{
    ALG_INFERENCE_NNIE = 0,
    ALG_INFERENCE_MXNET = 1,
    ALG_INFERENCE_CAFFE = 2,

    ALG_INFERENCE_BUTT
}ALG_INFERENCE_ENGINE_TYPE_E;


typedef struct
{
    //alg type
    ALG_INFERENCE_ENGINE_TYPE_E m_eInferenceType;
    union
    {
        struct
        {
            char    m_cWkFile[ALG_MODEL_NAME_SIZE];
        }stNnie;
        struct
        {
            char    m_cJsonFile[ALG_MODEL_NAME_SIZE];
            char    m_cParamsFile[ALG_MODEL_NAME_SIZE];
        }stMxnet;
        struct
        {
            char    m_cPrototxtFile[ALG_MODEL_NAME_SIZE];
            char    m_cCaffeModelFile[ALG_MODEL_NAME_SIZE];
        }stCaffe;
    }unModel;
    float           m_f32Threshold;
}ALG_INIT_PARAMS;

/*
** Rect
*/
typedef struct
{
    float   m_f32X1;
    float   m_f32Y1;
    float   m_f32X2;
    float   m_f32Y2;
}ALG_RECT_S;

/*
** Point
*/
typedef struct
{
    float   m_f32X;
    float   m_f32Y;
}ALG_POINT_S;

/*
** Points in face
*/
typedef struct
{
    ALG_POINT_S   m_stEyeL;
    ALG_POINT_S   m_stEyeR;

    // 5pts affine
    ALG_POINT_S   m_stNose;
    ALG_POINT_S   m_stMouseL;
    ALG_POINT_S   m_stMouseR;

    // 3pts affine
    ALG_POINT_S   m_stMouse;
}ALG_FACE_POINTS_S;

/*
** Rect result
*/
typedef struct
{
    float       m_f32Score;
    ALG_RECT_S  m_stRect;
}ALG_RECT_RESULT_S;

/*
** Face post
*/
typedef struct
{
    float       m_f32Roll;      //水平倾斜角
    float       m_f32Pitch;     //垂直偏转角度，俯仰角，up down
    float       m_f32Yaw;       //水平偏转角度，left，right
} ALG_FACE_POSE_S;

/*
** Landmark result
*/
typedef struct
{
    float               m_f32Score;
    INT32               m_s32PointsNum;
    ALG_POINT_S         m_stPoints[LMK_POINTS_MAX];
    INT32               m_s32WithPose;      //some lmk have pose,pfld
    ALG_FACE_POSE_S     m_stPose;
}ALG_FACELMK_RESULT_S;

/*
** FaceFeature result
*/
typedef struct
{
    float               m_f32Feature[FEATURE_SIZE_MAX];
    INT32               m_s32FeatureRealSize;
}ALG_FACEFEATURE_RESULT_S;

